/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package defaultPackage;

import entityBeans.ReplyEntity;
import entityBeans.ThreadEntity;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import sessionBeans.ThreadSessionBeanLocal;

/**
 *
 * @author h08182
 */
@ManagedBean(name="obiwankenobean")
@SessionScoped
public class MessageManagedBean {
    @EJB
    private ThreadSessionBeanLocal threadSessionBean;

    private String title;
    private String content;
    
    private ReplyEntity myReply;
    private ThreadEntity myThread;
    
    

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
    /**
     * Creates a new instance of MessageManagedBean
     */
    public MessageManagedBean() {
        myReply = new ReplyEntity();
        myThread = new ThreadEntity(); 
    }
    /**
     * Get a list of the messages for the specific thread
     * @param currentThread
     * @return List of message for the thread
     */
    public List<ReplyEntity> getMyReplies(ThreadEntity currentThread){
        System.out.println("currentThread id: ");
        return threadSessionBean.getMyReplies(currentThread);
   }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        
        this.title = "RE: " + myThread.getTitle();
    }
    
    public String createNewReply() {
        threadSessionBean.addNewPost(myThread, title, content);
        return "addReply";
    }
}
